using Bogus;
using System;
using System.Collections.Generic;
using System.Linq;
using Terra.Data.Entities.Identity;

namespace Terra.UnitTests.Helpers;

/// <summary>
/// 测试数据构建器，用于生成测试数据
/// </summary>
public static class TestDataBuilder
{
    private static readonly Faker Faker = new("zh_CN");

    /// <summary>
    /// 创建用户测试数据
    /// </summary>
    public static User CreateUser()
    {
        return new User
        {
            Id = Guid.NewGuid(),
            UserName = "testuser",
            NormalizedUserName = "TESTUSER",
            Email = "test@example.com",
            NormalizedEmail = "TEST@EXAMPLE.COM",
            PhoneNumber = "1234567890"
        };
    }

    /// <summary>
    /// 创建多个用户测试数据
    /// </summary>
    public static List<User> CreateUsers(int count = 3)
    {
        return Enumerable.Range(0, count)
            .Select(_ => CreateUser())
            .ToList();
    }

    /// <summary>
    /// 创建角色测试数据
    /// </summary>
    public static Role CreateRole(Action<Role> customization = null)
    {
        var role = new Role
        {
            Name = Faker.Commerce.Department(),
            Description = Faker.Lorem.Sentence(),
        };

        customization?.Invoke(role);
        return role;
    }
}